﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    //学号、姓名、性别、年龄、专业信息
    class Students
    {
        private int num;
        private string name;
        private string sex;
        private int age;
        private string major;

        public int Num
        {
            get
            {
                return this.num;
            }
            set
            {
                this.num = value;
            }
        }
        public string Name
        {
            get
            {
                return this.name;
            }
            set
            {
                this.name = value;
            }
        }
        public string Sex
        {
            get
            {
                return this.sex;
            }
            set
            {
                this.sex = value;
            }
        }
        public int Age
        {
            get
            {
                return this.age;
            }
            set
            {
                if (value < 0 || value > 128)
                {
                    this.age = 0;
                }
                else
                {
                    this.age = value;
                }
            }
        }
        public string Major
        {
            get
            {
                return this.major;
            }
            set
            {
                this.major = value;
            }
        }

        public void ToString()
        {
            Console.WriteLine($"学号{this.num} 姓名{name} 性别{sex} 年龄{age} 专业{major}");
        }
    }
}
